<?php 

include("conn.php");
mysql_query('SET NAMES UTF8'); 

class MyPrizeBean {

	public function userPay($phone, $passwd, $role) {

		switch ($role) {
			case 0:
				$type = 'user';
				break;
			
			case 1:
				$type = 'shop';
				break;			
			default:
				return false;
				break;
		}

		$passwd = '$10@w/2e3U4H' . $passwd;
		$res   = mysql_query("update " . $type . " set passwd = '" . $passwd . "' where phone = " . $phone);
		
		if($res) {
			return '200';
		} else {
			return '501';
		}
	}
}

// $_POST['phone'] = '17190173075';
// $_POST['passwd'] = '789456';
// $_POST['role'] = 1;

$userPay = new MyPrizeBean;
$res = $userPay->userPay($_POST['phone'],$_POST['passwd'],$_POST['role']);

if($res == '200') {
	$result = array('code' => $res, 'msg'=>'支付密码修改成功');
} else {
	$result = array('code' => $res, 'msg'=>'支付密码修改失败');
}

echo json_encode($result);
?>